package com.dongxing.concyrrency.chapter4;

import java.util.Optional;

/**
 * @author XavierDong
 **/
public class ThreadSimpleApi {

    public static void main(String[] args) {
        Thread thread = new Thread(() -> {

            Optional.of("Hello").ifPresent(System.out::println);
            try {
                Thread.sleep(100_000);
            } catch (InterruptedException e) {
                e.printStackTrace();
                Thread.currentThread().interrupt();
            }
        }, "t1");

        thread.start();

        // t1
        Optional.of(thread.getName()).ifPresent(System.out::println);
        // id
        Optional.of(thread.getId()).ifPresent(System.out::println);
        // 默认优先级为 5
        // 可以企图改变线程的优先级
        Optional.of(thread.getPriority()).ifPresent(System.out::println);

    }

}
